package com.zhengjiang.lambda;

/**
 * @author zhengjiang
 * @version 1.0.0
 * @description lambda表达式
 * @date 2021/5/29
 **/
class LambdaQs {

    public void eat(Eatable e){
        e.taste();
    }

    public void drive(Flyable f){
        String weather  = "晴天";
        f.fly(weather);
    }

    public void test(Addable add){
        int num1 = 5;
        int num2 = 3;
        System.out.println("加法运算add:"+num1 + "+" + num2 +"=" + add.add(5,3));
    }

    public static void main(String[] args) {
        LambdaQs qs = new LambdaQs();
        qs.eat(()-> System.out.println("I'm eating!"));
        qs.drive( weather-> {
            System.out.println("今天的天气:"  + weather);
            System.out.println("飞机飞行平稳");
        });
        qs.test((a,b)-> a + b);
    }
}

@FunctionalInterface
interface Eatable{
    void taste();
}
@FunctionalInterface
interface Flyable{
    void fly(String weather);
}
@FunctionalInterface
interface Addable{
    int add(int a,int b);
}
